package com.clm.config;

import com.clm.properties.AliOssProperties;
import com.clm.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author dinghuapeng
 * @Date 2023/11/1 9:08
 * @PackageName:com.clm.config
 * @ClassName: OssConfiguration
 * @Description: TODO 用于创建AliOSUtil对象
 * @Version 1.0
 */

@Configuration
@Slf4j
public class OssConfiguration {
    @Bean
    @ConditionalOnMissingBean//保证程序中只有一个工具类
    public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties){
        log.info("开始创建阿里云文件上传工具类对象");
        return new AliOssUtil(aliOssProperties.getEndpoint(), aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(), aliOssProperties.getBucketName());

    }
}
